/*LICENSE_BEGIN
 * ******************************************************************
 * All original parts of SoccerScope2003 have copyright (2003) by
 * Team YowAI, represented by Mr. Shuhei Shiota
 * The Department of Creative Informatics
 * The Graduate School of Information Science and Technology
 * The University of Tokyo
 * 
 * Additional classes (except libraries in /lib) were developed by 
 * the Dainamite Robocup-Team of the DAI-Labor, TU-Berlin 
 * (www.dai-labor.de)
 * 
 * Extended/new classes/packages are:
 *   soccerscope.analyzer.LogfileAnalyzer
 *   soccerscope.daistatistic.*
 *   soccerscope.daistatistic.charts.*
 *   soccerscope.daistatistic.tools.*
 *   soccerscope.db.*
 *   soccerscope.dialog.*
 *   soccerscope.model.PlayerWorldModel
 *   soccerscope.model.SimplePlayer
 *   soccerscope.net.AgentConnector
 *   soccerscope.training.*
 *   soccerscope.training.conditions.*
 * ******************************************************************
LICENSE_END*/
package soccerscope.model;

import java.util.LinkedList;

/**
 * the player data object contains some world model data
 * 
 */
public class PlayerWorldModel extends SimplePlayer {

    private static final long serialVersionUID = 8792476657351659236L;

    public double neckAngle = -9999;

    public double bodyAngle = -9999;

    public double ballPositionX = -9999;

    public double ballPositionY = -9999;

    public double ballSpeedX = -9999;

    public double ballSpeedY = -9999;

    public double ballInterceptX = -9999;

    public double ballInterceptY = -9999;

    // new visualization for mark-area

    public int oppNum = -1;

    public double markAreaX = -9999;

    public double markAreaY = -9999;

    public double markAreaRad = -9999;

    public boolean shouldMark = false;

    // finito mark-area

    public double oppInterceptX = -9999;

    public double oppInterceptY = -9999;

    public double offsideY = -9999;

    public boolean doneAPass = false;

    public double passToPlayer = 0;

    public SimplePlayer[] teammates = new SimplePlayer[11];

    public SimplePlayer[] opponents = new SimplePlayer[11];

    public SimplePlayer[] nextTeammates = new SimplePlayer[11];

    public SimplePlayer[] nextOpponents = new SimplePlayer[11];

    public int holes = 0;

    public boolean based_on_vi = true;

    public LinkedList<String> stateInfos = new LinkedList<String>();

    
    
    public PlayerWorldModel() {
        for (int i = 0; i < this.teammates.length; i++) {
            this.teammates[i] = new SimplePlayer();
            this.opponents[i] = new SimplePlayer();
            this.nextTeammates[i] = new SimplePlayer();
            this.nextOpponents[i] = new SimplePlayer();
        }
    }

    public void addState(String stateInfo) {

        this.stateInfos.add(stateInfo);
    }

    /**
     * gets the absolute ball speed
     * 
     * @return double
     */
    public double getBallSpeed() {
        if (this.ballSpeedX == -9999)
            return -9999;
        else
            return Math.sqrt(this.ballSpeedX * this.ballSpeedX + this.ballSpeedY
                    * this.ballSpeedY);
    }

    /**
     * gets the distance from player to ball
     * 
     * @return double
     */
    public double getPlayerToBallDistance() {
        if (this.positionX == -9999)
            return -9999;
        double x = this.positionX - this.ballPositionX;
        double y = this.positionY - this.ballPositionY;
        return Math.sqrt(x * x + y * y);
    }

    /**
     * @return Returns the stateInfos.
     */
    public LinkedList<String> getStateInfos() {

        return this.stateInfos;
    }
}
/**
 * $Log$
 * Revision 1.1.4.4  2006/11/23 09:41:03  endert
 * Added License Note at top of each *.java file.
 *
 * Revision 1.1.4.3  2006/11/13 16:28:30  endert
 * Removed Author from File
 *
 * Revision 1.1.4.2  2006/10/25 14:33:34  endert
 * Latest SoccerScope Version plus Database ability
 *
 * Revision 1.1.2.1  2006/06/26 07:04:23  benjaboe
 * Datamodell umgebaut
 * Revision 1.6 2006/05/17 17:09:55 endert Repaired
 * Layer for MarkOpponent and some new assesments for marking players
 * 
 * Revision 1.5 2006/05/17 14:08:06 endert New Layer for MarkArea
 * 
 * Revision 1.4 2006/04/05 22:48:00 wetzker added prediction of other players
 * state each player now contains a stateEvaluation (see StateTactic) used the
 * prediction for calculation the players of the next cycle (can be seen in the
 * gui) + new State (OpponentBallInterception) for prediction of opponents
 * removed bug in delayed intercetion (cause stamina loss for nothing)
 * meta_playmodes can be used now (added always playmode) improved attack in
 * line
 * 
 * Revision 1.3 2006/03/27 23:25:51 wetzker simplified stateEvaluation - moved
 * most of SimpleState into Abstract - moved most of StateEvaluation into
 * StateTactic adapted GUIUpdate - deleted state tables - only 1 state update
 * each cycle - gui should now be much faster (less holes)
 * 
 * Revision 1.2 2006/03/22 23:38:20 wetzker cleaned gui connection - wm is now
 * only send after an action - added more say + attentionTo logic set dribble
 * state value -20 percent for nightly tournament added state memory to LTM
 * 
 * Revision 1.1 2006/03/13 07:38:36 axle moved from ROOT/src for Maven 2
 * Buildsystem and Team/Soccerscope separation
 * 
 * Revision 1.20 2006/03/07 12:46:37 endert Merge after refactoring: - New
 * State-Interface: One Method for each action type - Action Bean removed -
 * ActionFactorys for helper methods, States calculate main-Action themselves -
 * formatted code - added State-List in Monitor (Context-Menu of Player) - other
 * smaller stuff
 * 
 * Revision 1.19.2.1 2006/02/25 22:07:47 wetzker formated
 * 
 * Revision 1.19 2006/02/22 16:05:05 endert This is done: - Rebound SoccerScope
 * to Agents (can be added or removed in config-file) - Situations now all
 * extend abstract class Situation - Refactorings: ActionBean _ removed from
 * Attributes - SoccerScope will automatically connect to host given in
 * Start-Call - Trainer uses the same host as soccerscope - Removed unused stuff
 * (old confs, bat, etc.) - Code formatted (good luck when merging) - organized
 * imports - all that i forgot to mention here Revision 1.18 2005/09/27 13:11:34
 * andpaul updated: state statistic/assessment
 * 
 * Revision 1.17 2005/09/26 22:18:34 andpaul updated: state statistic/values
 * 
 * Revision 1.16 2005/09/01 17:30:32 thyrion added quick'n'dirty display of
 * opponentinterceptionpoint
 * 
 * Revision 1.15 2005/09/01 08:29:07 andpaul added: showing actual player state
 * in WorldModelLayer (on the right site of the playing field)
 * 
 * Revision 1.14 2005/08/16 16:26:47 wetzker merged composite branch
 * 
 * Revision 1.12.4.2 2005/08/16 15:43:30 wetzker removed ball and player cloning
 * in getSelf, getBall -> should be much faster now merged with changes from
 * head
 * 
 * Revision 1.12.4.1 2005/07/15 19:53:46 wetzker added offside line
 * 
 * Revision 1.12 2005/06/20 17:30:52 andpaul documentation
 * 
 * Revision 1.11 2005/06/15 17:03:32 wetzker removed JIAC from Head + changes in
 * framework please report bugs or shortcomings some scenarios might not work
 * because of wrong imports
 * 
 * Revision 1.9.2.1 2005/06/15 16:44:57 wetzker final version
 * 
 * Revision 1.10 2005/06/12 18:52:16 thyrion fixed saving&loading of our
 * worldmodel (to load first open server log)
 * 
 * Revision 1.9 2005/05/22 16:50:39 andpaul changed init of holes to 0
 * 
 * Revision 1.8 2005/05/22 09:47:42 andpaul added: Speed and Position difference
 * of Opponents and Teammates
 * 
 * Revision 1.7 2005/05/17 21:45:58 andpaul added: support for world model
 * teammates and opponents
 * 
 * Revision 1.6 2005/05/17 18:28:10 andpaul added: min/max ball distance for
 * ball statistics
 * 
 * Revision 1.5 2005/05/16 18:40:38 andpaul added: if values not filled (-9999)
 * return -9999 in getSpeed and getBallSpeed
 * 
 * Revision 1.4 2005/05/16 15:33:42 andpaul added: getSpeed and getBallSpeed
 * 
 * Revision 1.3 2005/05/09 19:22:40 andpaul added: player pass statistic/charts
 * added: input fileds for maximum values added: holes statistic/charts
 * 
 * Revision 1.2 2005/05/02 19:44:19 andpaul added two new attributs:
 * ballInterceptX and ballInterceptY which stores the ball interception point
 * coordinates
 * 
 * Revision 1.1 2005/04/25 14:55:37 andpaul first version of the gui dai-namite
 * player worldmodel history
 * 
 * 
 * 
 */
